﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Forms;
using Traceability.Commont.Domains.AnimalsDomainFiles;
using Traceability.Commont.DTOs;

namespace Butcher.winform.EnterpriseForms.ShopFrom
{
    public partial class ShopListFrom : Form
    {
        public ShopListFrom()
        {
            InitializeComponent();
        }

        private void ShopListFrom_Load(object sender, EventArgs e)
        {
            string url = @"http://localhost:5229/api/Batch/getShop";
            HttpClient client = new HttpClient();
            WaitingCirclePagDTO res = new WaitingCirclePagDTO();
   
            var content = new StringContent(JsonSerializer.Serialize<WaitingCirclePagDTO>(res));
            content.Headers.Remove("Content-Type");
            content.Headers.Add("Content-Type", "application/json");
            string result = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
            JObject info = JObject.Parse(result);
            var aaa = info["date"].Value<JArray>();
            List<Shopping> enterprises = aaa.ToObject<List<Shopping>>();
            dataGridView1.DataSource = enterprises;
        }
    }
}
